package main

import (
	"math/rand"
	"runtime"

	log "github.com/Sirupsen/logrus"
)

func printStack() {
	if err := recover(); err != nil {
		log.Errorf("%v", err)
		i := 0
		funcName, file, line, ok := runtime.Caller(i)
		for ok {
			log.Printf("frame %v:[func:%v,file:%v,line:%v]\n", i, runtime.FuncForPC(funcName).Name(), file, line)
			i++
			funcName, file, line, ok = runtime.Caller(i)
		}
	}
}

func randPort() int {
	return 10000 + rand.Intn(50000)
}
